#include "Listener.h"
#include "Room.h"
#include <string>
#include <iostream>
#include <boost\thread.hpp>
using namespace std;

using namespace boost;
using boost::asio::ip::tcp;

class Server
{
public:
	Server():endpoint(tcp::v4(), 6001),listener(io_service,endpoint){}
	void start()
	{
		th=new thread(&Server::run,this);
		cout<<"server has started.."<<endl;
	}
	void run()
	{
		io_service.run();
	}
	void wait()
	{
		th->join();
	}
	void broadcast(char* p)
	{
		Room::getInstance().broadcast(p);
	}
private:
	tcp::endpoint endpoint;
	boost::asio::io_service io_service;
	Listener listener;
	thread* th;

};